package cn.globalph.housekeeper.ui.splash

import android.content.Intent
import android.os.Handler
import cn.globalph.housekeeper.R
import cn.globalph.housekeeper.data.TokenStorage
import cn.globalph.housekeeper.ui.BaseActivity
import cn.globalph.housekeeper.ui.login.LoginActivity
import cn.globalph.housekeeper.ui.main.MainActivity

class SplashActivity : BaseActivity() {

    override fun initView() {
        setContentView(R.layout.activity_splash)

        val handler = Handler()
        handler.postDelayed({
            TokenStorage.loadData(getContext())
            if(TokenStorage.token == null
                || TokenStorage.profile == null){
                startActivity(Intent(getContext(),LoginActivity::class.java))
            }else{
                startActivity(Intent(getContext(),MainActivity::class.java))
            }
            finish()
        },1000)
    }

}
